Skip to main content

Tools Overview

Tools give BindAI agents the ability to interact with application code and external systems. A tool is a callable capability that an agent can use when additional functionality is required. Tools can be used for:
  • Calling APIs
  • Querying databases
  • Searching documents
  • Performing calculations
  • Reading or writing application data
  • Executing business logic
  • Integrating with external services
Tools extend an agent beyond language generation by giving it access to deterministic operations and application capabilities.

What Is a Tool?

A BindAI tool represents an operation that an agent can execute. The underlying operation can be a normal Python function.
A tool can then be attached to an agent:
Tools can also be registered during agent construction with the builder API.

Creating a Tool

BindAI provides a tool decorator for defining tools.
The decorator allows BindAI to treat the function as a tool that can be registered with an agent. Python type hints should be used whenever possible. They make the tool interface clearer and provide information that can be used when the tool is exposed to a language model.

Registering a Tool

A tool can be registered with an agent using .tool().
The builder keeps agent configuration in one place while allowing tools to be attached as capabilities.

Registering Multiple Tools

Use .tools() when an agent needs several capabilities.
Multiple tools allow the model to select the capability that best matches the current request. For example:

How Tool Calling Works

At a high level, tool-enabled execution follows this process:
The model determines whether a registered tool is appropriate for the request. When the model requests a tool, BindAI executes the corresponding callable and provides the result back to the ongoing agent execution. The model can then use the tool result when producing the final response or deciding what to do next.

Why Use Tools?

A language model does not automatically have access to application-specific capabilities or current external data. Tools can provide access to:
  • Live data
  • Internal APIs
  • Databases
  • Deterministic calculations
  • Application state
  • Business operations
  • External services
  • Knowledge retrieval
For example, instead of asking a model to perform a calculation itself, an application can expose a deterministic Python operation:
The agent can use the operation when appropriate.

Tool Parameters

Tool parameters are defined by the Python function signature.
This tool exposes two parameters:
  • query — the search query
  • limit — the maximum number of results
Type hints communicate the expected parameter types. Default values can be used when a parameter is optional. Prefer explicit, descriptive parameters over ambiguous arguments.

Type Hints

Type hints make tools easier to understand and integrate.
The signature communicates:
Use clear type annotations for tool parameters whenever possible. They make tool contracts easier for both developers and language models to understand.

Tool Descriptions

Tool descriptions should clearly explain what an operation does. For example:
A clear description helps the model determine when the tool is appropriate. Good descriptions should explain:
  • What the tool does
  • When it should be used
  • What its important parameters represent
  • What kind of result it returns
Avoid descriptions that are vague or overly broad.

Multiple Tool Calls

An agent execution can involve more than one tool call. For example:
This allows an agent to combine several capabilities during a single request. The execution system coordinates the interaction between the model, tools, and subsequent model responses. Applications should avoid assuming that every request results in exactly one tool call.

Tool Execution

When a model requests a registered tool, BindAI executes the associated callable. Conceptually:
The returned value becomes part of the ongoing execution and can be used by the model to continue the task. This allows an agent to combine language reasoning with deterministic application operations.

Tool Results

Tool execution produces a result that is handled by BindAI’s tool execution system. The result can represent successful output or an execution error. Application code should generally allow the agent execution layer to coordinate tool results rather than implementing provider-specific tool-call handling. For example, a tool can simply return its application result:
The agent execution system handles the interaction between the tool and the language model.

Tool Errors

Tools can fail during execution. For example:
Applications should design tools to handle expected failures appropriately. For external systems, return or raise clear errors that provide enough information for the surrounding execution flow to understand what went wrong. Tool failures should not expose unnecessary internal details such as credentials, private connection information, or sensitive application state.

Reusing Tools

Tools can be reused across multiple agents.
This keeps shared functionality in one implementation instead of duplicating the same logic across agents. Reusable tools are particularly useful for common capabilities such as:
  • Search
  • Data retrieval
  • Calculations
  • Internal APIs
  • External service operations

Tools and Agent Configuration

Tools are part of an agent’s capabilities and can be configured alongside its model, instructions, memory, knowledge, and other execution features. For example:
This keeps the agent’s capabilities explicit and close to the rest of its configuration. For larger projects, tools can be organized into dedicated modules:
The exact project structure is application-dependent.

Tool Context

Some tools may need access to information beyond their explicit function arguments. BindAI tools can participate in the execution context used by the agent. This can be useful for applications involving:
  • Runtime metadata
  • Execution state
  • Workflow state
  • Application state
  • User-specific information
  • External service configuration
The exact context available to a tool depends on the tool and execution mechanism being used. Keep tool interfaces explicit whenever possible. Use execution context when the capability genuinely depends on runtime information.

Tools and Memory

Tools can work alongside BindAI memory. For example, an agent might use:
Memory provides conversation or application context, while tools provide executable capabilities. The two mechanisms solve different problems and can be combined in the same agent.

Tools and Knowledge

Tools can also complement BindAI’s knowledge and retrieval capabilities. For example:
Knowledge systems are useful for retrieving information from indexed content. Tools are useful when the agent needs to execute an operation or access a live external system.

Tools and Workflows

Tools can participate in workflow-driven applications. A workflow can coordinate agent execution while tools provide individual capabilities. Conceptually:
Use tools for individual operations and workflows for larger orchestration logic. Avoid putting complex multi-step orchestration directly inside a single tool.

External Services

Tools are a natural interface for external services. Examples include:
  • REST APIs
  • Databases
  • Search services
  • SaaS platforms
  • Internal business systems
  • Other application services
For repeated integrations, BindAI’s Connections package can provide a dedicated integration boundary. A tool can then expose a focused operation while the connection manages communication with the external service. For example:
This keeps external service details separate from the agent’s high-level behavior.

Designing Good Tools

Good tools should have a clear and limited responsibility. For example, prefer:
over a single tool that attempts to handle:
Small tools are easier for developers and language models to understand. Focused tools also make testing, error handling, reuse, and maintenance easier.

Tool Security

Tools can give an agent access to real application capabilities, so they should be treated as application boundaries. Consider:
  • Validate external inputs.
  • Limit access to sensitive operations.
  • Avoid exposing credentials to the model.
  • Avoid returning secrets in tool results.
  • Apply appropriate authorization in application code.
  • Keep destructive operations narrowly scoped.
  • Validate data before writing to external systems.
The language model should not be treated as a security boundary. Authorization and access control should remain enforced by the application and the systems behind the tool.

Tool Side Effects

Some tools only read information, while others modify application state. Examples of read operations:
Examples of state-changing operations:
State-changing tools should be designed carefully. Where appropriate, applications should validate important parameters and require explicit confirmation for sensitive or irreversible actions.

Testing Tools

Tools should be tested independently from the language model whenever possible. A deterministic tool can be tested like normal Python application code:
Tool integration tests can then verify that the tool is correctly registered with an agent. Useful test areas include:
  • Tool registration
  • Parameter handling
  • Successful execution
  • Error handling
  • External service failures
  • Security and authorization
  • Tool output formatting
Keeping tool logic independently testable makes agent behavior easier to debug.

Tool Calling and Providers

Tool calling is coordinated between BindAI and the selected model provider. The provider determines how tool calls are represented to the model, while BindAI manages the application-level tool execution. This architecture allows tools to remain largely independent of a specific provider. Conceptually:
This separation helps applications switch providers without rewriting their core tool implementations.

Tools and Multi-Agent Systems

Tools can be assigned to different specialist agents. For example:
This allows each specialist agent to expose only the capabilities relevant to its role. Keeping tool sets focused can make multi-agent systems easier to reason about and maintain.

Best Practices

  • Give each tool one clear responsibility.
  • Use descriptive function and parameter names.
  • Add Python type hints.
  • Write concise and accurate tool descriptions.
  • Validate external inputs.
  • Keep tool outputs focused and useful.
  • Handle expected failures gracefully.
  • Avoid exposing secrets through tool inputs or outputs.
  • Apply authorization in application code.
  • Keep destructive operations narrowly scoped.
  • Avoid unnecessary side effects.
  • Reuse common tools across agents.
  • Prefer several focused tools over one large tool.
  • Test tools independently from the language model.
  • Use workflows for complex orchestration.
  • Use dedicated connections when an external integration benefits from a reusable connection boundary.

Summary

Tools extend BindAI agents with capabilities beyond language generation. The primary registration APIs are:
and:
Tools can be created from Python functions or with the @tool decorator:
A complete builder-based agent can then expose the tool:
Once registered, tools can participate in agent execution and allow models to interact with application logic, external services, deterministic operations, memory, knowledge, and workflows. The result is an agent that can do more than generate text: it can use application capabilities and take actions as part of its execution.